const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('users', {
    user_id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    nickname: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: "",
      comment: "昵称"
    },
    username: {
      type: DataTypes.STRING(50),
      allowNull: true,
      defaultValue: "",
      comment: "用户名"
    },
    password: {
      type: DataTypes.CHAR(32),
      allowNull: true,
      defaultValue: "",
      comment: "密码"
    },
    avatar: {
      type: DataTypes.STRING(200),
      allowNull: true,
      defaultValue: "",
      comment: "头像"
    },
    sign: {
      type: DataTypes.STRING(200),
      allowNull: true,
      defaultValue: "",
      comment: "个性签名"
    },
    add_date: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "注册时间"
    },
    status: {
      type: DataTypes.TINYINT,
      allowNull: true,
      defaultValue: 0,
      comment: "会员状态。 0-正常 1-禁用"
    },
    level: {
      type: DataTypes.TINYINT,
      allowNull: true,
      defaultValue: 0,
      comment: "会员等级"
    }
  }, {
    sequelize,
    tableName: 'users',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "user_id" },
        ]
      },
    ]
  });
};
